#include<bits/stdc++.h>
using namespace std;
int T,n,m,L,V,ans1,ans2;
int d[100005],v[100005],a[100005],x[100005][2],p[100005];
bool G[25][25],chk[25];
int ans[25];
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	scanf("%d",&T);
	while(T--){
		memset(chk,0,sizeof chk);
		memset(G,0,sizeof G);
		scanf("%d%d%d%d",&n,&m,&L,&V);
		if(n<=20){
			
		for(int i=1;i<=n;i++){
			scanf("%d%d%d",&d[i],&v[i],&a[i]);
			if(a[i]==0){
				if(v[i]>V) x[i][0]=d[i],x[i][1]=L;
				else x[i][0]=x[i][1]=-1;
			}
			else if(a[i]>0){
				double xxx=d[i]*1.0+0.5/a[i]*(V*V-v[i]*v[i]);
				int xx=(int)(floor(xxx))+1;
				if(xx<d[i]) x[i][0]=d[i],x[i][1]=L;
				else if(xx>L) x[i][0]=x[i][1]=-1;
				else x[i][0]=xx,x[i][1]=L;
			}
			else{
				double xxx=d[i]*1.0+0.5/a[i]*(V*V-v[i]*v[i]);
				int xx=(int)(ceil(xxx))-1;
				if(xx>L) x[i][0]=d[i],x[i][1]=L;
				else if(xx<d[i]) x[i][0]=x[i][1]=-1;
				else x[i][0]=d[i],x[i][1]=xx;
			}
		}
		/*
		for(int i=1;i<=n;i++){
				cout<<x[i][0]<<" "<<x[i][1]<<endl;
		}
		*/
		// now the problem is not related with d,v,a, and is related with x (which is [l,r]) and p
		for(int i=1;i<=m;i++){
			scanf("%d",&p[i]);
			for(int j=1;j<=n;j++){
				if(p[i]<=x[j][1] && p[i]>=x[j][0]){
					G[i][j]=1;
					chk[j]=1;ans[i]++;
				}
			}
		}
		int cnt=0;
		for(int i=1;i<=n;i++){
			if(chk[i]) cnt++;
		}
		printf("%d ",cnt);
		// first step, but it is n^2, and i'll use the var 'cnt' again
		cnt=0;
		while(true){
			int maxn=0;
			for(int i=1;i<=m;i++){
				ans[i]=0;
				for(int j=1;j<=n;j++){
					if(G[i][j]==1) ans[i]++;
				}
				maxn=max(maxn,ans[i]);
			}
			if(maxn==0) break;
			for(int i=1;i<=m;i++){
				if(maxn==ans[i]){
					maxn=i;
					break;
				}
			}
			for(int j=1;j<=n;j++){
				if(G[maxn][j]==1){
					G[maxn][j]=0;
					for(int k=1;k<=m;k++){
						G[k][j]=0;
					}
				}
			}
			cnt++;
		}
		printf("%d\n",m-cnt);
		
		
		}
		else{
		
		
		for(int i=1;i<=n;i++){
			scanf("%d%d%d",&d[i],&v[i],&a[i]);
			if(a[i]==0){
				if(v[i]>V) x[i][0]=d[i],x[i][1]=L;
				else x[i][0]=x[i][1]=-1;
			}
			else if(a[i]>0){
				double xxx=d[i]*1.0+0.5/a[i]*(V*V-v[i]*v[i]);
				int xx=(int)(floor(xxx))+1;
				if(xx<d[i]) x[i][0]=d[i],x[i][1]=L;
				else if(xx>L) x[i][0]=x[i][1]=-1;
				else x[i][0]=xx,x[i][1]=L;
			}
			else{}
		}
		ans1=ans2=0;
		for(int i=1;i<=m;i++){
			scanf("%d",&p[i]);
		}
		for(int i=1;i<=n;i++){
			if(x[i][1]!=-1 && x[i][0]<=p[m]) ans1++;
		}
		if(ans1!=0) ans2=m-1;
		else ans2=m;
		printf("%d %d\n",ans1,ans2);	
			
		}
	}
	return 0;
	// Final Step!!! (Muse Dash & Phigros)
}

// Sensei...
// I've discussed with you about the one who has a great responsibility.
// I didn't understand that time the thing you talked to me.
// About rights, resposibilities, and the thing on the extention of the line of time----YOUR CHOICE
// Where all 'Miracles' begin...
// from 'Blue Archive'

// Feiyang is my queen, confident and shines as lightning (Double Rhyme)
// Feiyang Wo Nv Wang, Zi Xin Fang Guang Mang
// Show my sincere love to SZZX-Shaoyu2024-Class1 Chen Feiyang
// Chu! Kawaii ku te gomen!
// Hatsune Miku is the 1st princess in the whole world!!!
// I want to see 'Oni-chan ha oshimai!' 2nd season!!! Please!!!

// In fact, I have no idea how to caculate the second number
// I've tried a n^3 method...but that clearly won't work =(
// I won't be trying n,m<=3000, instead, I use out another code ( n,m<=20 or a>=0 )
// So... I would still get 60pts 
